<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>首页</title>
	<link rel="stylesheet" href="css/loading.css" type="text/css" media="all">
	<link rel="stylesheet" href="css/bootstrap.css" type="text/css" media="all">
	<link rel="stylesheet" href="css/main.css" type="text/css" media="all">
	<link rel="stylesheet" type="text/css" href="css/demo.css" />
	<link rel="stylesheet" type="text/css" href="css/jquery.niftymodals.css" /> 	
</head>
<body>
<div class="wrapper">
    <!--背景图片-->
    <div id="web_bg" style="background-image: url(./img/bg-0.jpg);"></div>
    <!--其他代码 ... -->
	<div class="title">
		<span style="font-size:46px; color:#333;"><b style="margin-left:30px;">健康评估与康复筛查系统</b></span>
		<br>
		<span style="font-size:46px; color:#333;"><b style="margin-left:30px;">医护管理端</b></span>
	</div>
	
	<!--<iframe class="iframe_case" id="iframe_app" style="display:none;" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" oallowfullscreen="true" msallowfullscreen="true" name="mapFrame" scrolling="yes" frameborder="0"></iframe>-->
	<div class="container">
		<div class="item-1"></div>
		<div class="item-2"></div>
		<div class="item-3"></div>
		<div class="item-4"></div>
		<div class="item-5"></div>
	</div>
		<button class="md-trigger" id="md-trigger-1" data-modal="modal-offline" style="display:none;">本地连接错误</button>
		<button class="md-trigger" id="md-trigger-2" data-modal="modal-server-unlink" style="display:none;">服务端连接错误</button>
	<div id="select" style="display:none;">
		<!--<button type="button" class="md-trigger" id="app_button" style="display:none;" onclick="$('#iframe_app').show();$('#set_button').show();">
			<b>进  入</b>
		</button>-->
	</div>
	<div class="setting">
		<!--<button class="home_button" id="seturl" data-modal="modal-server-settings">-->
		<button class="md-trigger" id="seturl" data-modal="modal-server-settings" style="border:none; display:none;">
		<svg t="1655278312438" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3360" width="64" height="64" style="padding-top:0.3rem;">
			<path d="M983.473546 628.087716C984.898063 636.572877 984.588385 646.730296 982.358707 658.683848 980.314834 670.637394 976.784512 682.838687 971.829673 695.101911 966.874834 707.427072 960.929029 718.513526 953.930317 728.361267 946.93161 738.270945 939.065805 745.269652 930.704512 749.481267 922.219351 753.754813 914.849029 755.860618 908.469673 755.860618 902.152253 755.860618 895.153546 754.498038 887.41161 751.649009 880.412902 749.543199 871.556127 747.623199 861.027092 745.827072 850.37419 744.092877 839.721288 743.783199 828.758707 744.77417 817.858063 745.827072 806.957414 748.118687 796.118707 751.587072 785.279995 755.055457 775.803868 761.125135 768.185805 769.548365 751.277414 787.138038 741.305805 807.205135 738.518707 829.749652 735.73161 852.29417 738.890317 873.723848 748.056771 894.162555 755.055483 908.283848 754.002575 922.281267 744.898063 936.402555 740.686449 942.038687 733.873546 947.860618 724.830966 953.806428 715.664512 959.81417 705.569029 965.264492 694.730317 970.219331 683.89161 975.17417 672.37161 979.01417 660.356127 981.863199 648.402575 984.588365 637.873546 986.012877 628.645156 986.012877 622.327736 986.012877 616.443868 983.535457 610.745805 978.642555 605.17161 973.687716 601.33161 968.361267 599.101932 962.787072L598.049029 962.787072C590.307092 940.923848 577.114834 922.157394 558.472253 906.301911 539.829673 890.446428 518.21419 882.518687 493.501932 882.518687 469.594835 882.518687 447.917416 890.446428 428.593545 906.301911 409.207739 922.157394 395.643868 940.61417 387.901932 961.73417 384.37161 970.219331 379.107094 976.350945 372.046448 980.252877 365.109674 984.092877 357.367739 986.012877 348.882577 986.012877 339.034835 986.012877 327.948384 984.278687 315.623222 980.686428 303.298061 977.156106 290.9729 972.758687 278.647739 967.49417 266.322577 962.229652 255.236126 956.036106 245.388384 948.975457 235.540642 941.97675 228.170319 934.916106 223.21548 927.917394 219.685158 922.962555 217.765158 917.140618 217.393545 910.513526 217.021932 903.824492 219.685158 894.472233 225.321287 882.518687 233.063222 866.291589 236.036126 847.834813 234.301932 827.024492 232.567739 806.276106 223.587094 787.076106 207.359997 769.486428 197.512255 758.895457 185.558706 752.082555 171.499352 748.923848 157.378061 745.703199 144.061932 744.526428 131.365158 745.207716 116.562577 745.889009 101.450319 748.738038 85.966448 753.692877 76.118706 756.479974 66.270964 755.73675 56.361287 751.525135 48.619352 748.738038 41.434835 742.234813 34.683868 732.077394 27.994835 721.858038 22.049029 710.523848 16.722577 698.260618 11.458061 685.935457 7.432255 673.300618 4.583223 660.232233 1.796126 647.225779 1.0529 636.510945 2.477416 628.025779 4.583223 612.541911 11.581932 602.69417 23.597416 598.482555 44.717416 589.997394 63.669674 576.123848 80.578061 556.738038 97.486448 537.352233 105.909674 515.73675 105.909674 491.767717 105.909674 467.17933 97.486448 445.687717 80.578061 427.354814 63.669674 409.021911 44.655481 395.705782 23.597416 387.22062 17.403868 385.238685 12.139352 380.159975 7.927739 372.046427 3.716126 363.932878 1.548384 355.633524 1.548384 347.272233 1.548384 338.105782 2.9729 327.886427 5.759997 316.614169 8.547093 305.341911 12.263223 294.441266 16.846448 283.850298 21.429674 273.321266 26.756126 263.65933 32.701932 254.802556 38.709674 246.069652 45.2129 239.504492 52.21161 235.292878 57.847739 231.762556 63.359997 230.399975 68.624513 231.081266 73.889029 231.762556 79.710964 233.187072 86.028384 235.292878 107.148384 243.77804 129.13548 246.37933 152.05161 243.22062 174.905803 240.061911 195.158706 230.028362 212.748384 213.181911 221.17161 204.69675 227.303222 194.291588 231.205158 182.028362 235.045158 169.641266 237.584513 157.501911 238.57548 145.548362 239.690319 133.594814 239.690319 122.694169 238.57548 112.846427 237.584513 102.93675 236.65548 95.93804 235.97419 91.726427 234.549674 87.514814 233.310964 82.559975 232.258061 76.923846 231.205158 71.287717 231.762577 66.332878 233.806448 62.121266 238.018061 52.273524 245.57419 43.664491 256.536771 36.294169 267.437416 28.923846 279.205158 22.730298 291.901932 17.775459 304.598706 12.882556 316.923868 9.228362 328.877416 6.689007 340.830964 4.211588 350.369029 2.972878 357.367739 2.972878 366.472255 2.972878 373.718706 5.945782 379.045158 11.953524 384.309674 17.961266 387.963868 24.154814 390.069674 30.472233 397.81161 49.486427 410.508384 66.147072 428.098061 80.639975 445.687739 95.070943 466.498061 102.317394 490.405158 102.317394 515.055483 102.317394 536.856771 95.442556 555.870966 81.692878 574.885156 67.943201 588.263224 50.53933 596.005156 29.41933 598.792253 23.783201 603.25161 17.961266 609.197414 12.015459 615.143224 6.007717 621.274834 3.034814 627.716127 3.034814 637.501932 3.034814 648.278707 4.397395 659.922575 7.246427 671.566449 10.033524 683.024512 13.935459 694.172902 18.890298 705.569029 23.783201 715.97419 30.162556 725.388385 37.904491 734.926449 45.646427 742.420644 54.069652 748.118707 63.236104 751.649029 68.872233 752.701932 75.003846 751.277414 81.692878 749.852902 88.381911 748.490317 93.150943 747.065805 95.93804 737.899351 116.37675 735.112253 137.806427 738.580644 160.350943 742.110966 182.833524 752.392253 202.590943 769.176771 219.49933 786.085156 236.407717 806.895483 245.69804 831.483868 247.494169 856.13419 249.228362 879.050317 245.202556 900.170317 235.354814 905.744512 231.824492 912.619351 230.399975 920.732902 231.143201 928.846449 231.886427 935.597414 235.045136 941.295483 240.61933 951.824512 250.467072 961.114834 265.455459 969.228385 285.522556 977.341932 305.589652 982.792253 325.842556 985.579351 346.21933 987.003868 358.172878 985.083868 367.525136 979.881288 374.214169 974.554834 380.841266 969.104512 385.30062 963.406449 387.406427 941.605156 395.148362 923.024512 408.712233 907.540644 428.036104 892.056771 447.359975 884.314834 469.409008 884.314834 493.997394 884.314834 517.966428 890.818063 538.900618 903.762575 556.861911 916.830966 574.761267 933.863224 587.643848 954.921288 595.385779 959.876127 598.172877 964.087736 601.021911 967.618063 603.809009 975.359995 610.126428 980.686449 618.239974 983.473546 628.087716L983.473546 628.087716 983.473546 628.087716ZM492.510964 723.09675C524.159995 723.09675 554.136771 717.089009 582.193546 705.135457 610.37419 693.181911 634.838707 676.645135 655.649029 655.525135 676.459351 634.343199 692.810317 609.940618 704.763868 582.131589 716.717414 554.322555 722.663224 524.531589 722.663224 492.944492 722.663224 461.233524 716.717414 431.504492 704.763868 403.757394 692.810317 375.948362 676.459351 351.607717 655.649029 330.85933 634.838707 310.110943 610.436127 293.69804 582.193546 281.744492 554.136771 269.790943 524.098063 263.783201 492.510964 263.783201 460.861932 263.783201 431.070964 269.790943 403.261932 281.744492 375.514835 293.69804 351.17419 310.110943 330.487739 330.85933 309.739352 351.607717 293.326448 375.948362 281.3729 403.757394 269.419352 431.504492 263.41161 461.295459 263.41161 492.944492 263.41161 524.593526 269.419352 554.322555 281.3729 582.131589 293.326448 609.878687 309.739352 634.343199 330.487739 655.525135 351.236126 676.645135 375.576771 693.119974 403.323868 705.135457 431.1329 717.089009 460.861932 723.09675 492.510964 723.09675L492.510964 723.09675 492.510964 723.09675Z" p-id="3361" fill="#707070">
			</path>
		</svg>
	</button>
	</div>
</div>
<div class="md-container md-effect-1" id="modal-offline">
	<div class="md-content">
		<h3>本地网络连接错误</h3>
		<div>
			<p>请检查本机是否连接到路由器上！</p>
			<ul>
				<li><strong>如果是有线连接，</strong> 请检查设备的网口是是否有网线连接。</li>
				<li><strong>如果是无线连接，</strong> 请进入设置页面检查设备是否连接到wifi网络。</li>
			</ul>
			<button class="md-close" onclick=location.reload()>重 试</button>
		</div>
	</div>
</div>
<div class="md-container md-effect-1" id="modal-server-unlink">
	<div class="md-content">
		<h3>服务端连接错误</h3>
		<div>
			<p>请检查与服务端的连接是否正常！</p>
			<ul>
				<li><strong>如果是网络连接问题，</strong> 请确保设备到服务端的连接正常。</li>
				<li><strong>如果是服务端地址连接不上，</strong> 请检查设备配置的服务端的地址和端口是否正确。</li>
			</ul>
			<button class="md-close" onclick=location.reload()>重 试</button>
		</div>
	</div>
</div>

<div class="md-container md-effect-1" id="modal-server-settings">
	<div class="md-content" style="background:#009688">
		<h3>设置
		<button class="close" data-dismiss="modal">
			<span aria-hidden="true" style="position:relative;font-size:44px;color:white;">&times;</span></h3>
		</button>
		<div>
			<p>修改服务端地址和端口</p>
			<ul>
				<label>服务端URL</label>
				<input type="text" class="form-control" placeholder="" autofocus="autofocus" id="server_url">
				<label>服务端端口</label>
				<input type="text" class="form-control" placeholder="" id="server_port">
				<label>应用路径</label>
				<input type="text" class="form-control" placeholder="" id="server_path">
			</ul>
			<button class="md-close" onclick=setServerUrl() id="saveUrl">保 存</button>
			<a class="md-close" onclick=clearLocalUrl()>清 除</a>
		</div>
	</div>
</div>

	<!-- Default-JavaScript -->   <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
	<!-- Bootstrap-JavaScript --> <script type="text/javascript" src="js/bootstrap.js"></script>
	<script src="js/jquery.niftymodals.js"></script>
	<script>
	
		$(document).ready(function onLine(callback){

			//var iframeapp = document.getElementById('iframe_app');
			//检查本地存储中是否保存医护管理应用的网址，如果没有就使用默认的地址，如果有，就是用本地存储的地址
			//需要下载最新版本的webview：https://apkbog.com/en/apk/android-system-webview
			
			if (!localStorage.getItem('url')){
				src="https://daisyui.com/docs/themes/";
				console.log("本地存储中没有设置url，如果没有使用默认路径：" + src);
				linkChecking(src);
			}else{
				let newurl = localStorage.getItem('url');
				let newport = localStorage.getItem('port');
				let newpath = localStorage.getItem('path');
				document.getElementById("server_url").value = newurl;
				document.getElementById("server_port").value = newport;
				document.getElementById("server_path").value = newpath;
				baseurl = newurl + ":" + newport;
				if (!newpath){
					src = "https://" + baseurl;
				}else{
					src = "https://" + baseurl + "/" + newpath;
				}
				
				console.log("本地存储中有设置url，采用这个路径访问" + baseurl);
				console.log("这个地址是：" + src);				
				linkChecking(src);
			}
			//console.log("iframe的src是：" + src);
			
			
			function linkChecking(url){
				var img = new Image();
				//var myiframe = document.getElementById('iframe_app');
				//img.src = url + '/x.jpg';
				img.src = 'https://www.baidu.com/favicon.ico?_t=' + Date.now();
				console.log("验证地址是：" + img.src);
				if(navigator.onLine){
					console.log('本地网络连接成功');
					img.onload=function(){
						console.log('服务端连接成功');
						//iframeapp.src = url; 
						setTimeout(function() {
						  $('body').addClass('loaded'); 
						  //$('#app_button').click();
						  top.location= url;
						}, 2000);
						
						
					};
					img.onerror=function(){
						console.log('服务端连接失败');
						setTimeout(function() {
							$('body').addClass('loaded');
							$('#md-trigger-2').click();
							$('#seturl').show();
						}, 2000);
						
					}
				}else{
					console.log('本地网络连接失败');
					
					setTimeout(function() {
						$('body').addClass('loaded');
						$('#md-trigger-1').click();
						$('#seturl').show();
						}, 2000);
					
				};
				
			}			
			
		});
	
	</script>
	<script>
		function homeback(){
			var historyLen = window.history;
			window.history.go(-(historyLen - 1));
		};
		function setServerUrl(){
			 var myurl = $("#server_url").val();
			 var myport = $("#server_port").val();
			 var mypath = $("#server_path").val();
			 console.log("取到的url地址值：" + myurl + ":" + myport + "/" + mypath);
			 if (!myurl){
				console.log("新设置的url为空！");
				
			 }else{
				localStorage.setItem("url",myurl);
				localStorage.setItem("port",myport);
				localStorage.setItem("path",mypath);
				let current_url = localStorage.getItem('url');
				let current_port = localStorage.getItem('port');
				let current_path = localStorage.getItem('path');				 
				console.log("设置的新地址是：" + current_url + ":" + current_port + current_path);
				location.reload();
			 }			 
		};
		function clearLocalUrl(){
			localStorage.clear();
			location.reload();
		}
	</script>

</body>
</html>